{extend name="$_admin_layout"}

{block name="tpl_vars"}
    {assign name="page_title" value="用户管理" /}
{/block}

{block name="main-content"}
    <form id="user_list" class="table-form table-manager">
        {:helper('admin/form')->render_hidden('mp_number', $mp_number)}
        
        <div class="box box-blue no-heading">
            <div class="box-body">

                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-fixed-toolbar">
                            {include file='wechat@admin/common/mp_list'}
                            {:helper('admin/toolbar')->render_button('下载用户数据', 'fa fa-download', 'btn btn-primary ajax-post', array('url' => $_controller->url('download'), 'confirm-text' => '该操作会将用户数据从微信服务器下载到本地数据库。<br/>如果用户数据较多，可能会等待一定时间。<br/><br/>确定执行该操作吗？'))}
                            {:helper('admin/toolbar')->render_button('更新用户信息', 'fa fa-clone', 'btn btn-primary ajax-post selected disabled', array('url' => $_controller->url('bulk_update'), 'confirm-text' => '该操作针对所选用户，从微信服务器上获取用户最新信息，然后更新到本地数据库。<br/><br/>确定执行该操作吗？'))}
                            <div class="btn-group" role="group">
                                <button type="button" class="btn btn-warning selected disabled dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    <span>黑名单</span>
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li><a href="{:$_controller->url('add_blacklist')}" class="ajax-post">加入黑名单</a></li>
                                    <li><a href="{:$_controller->url('remove_blacklist')}" class="ajax-post">从黑名单中移除</a></li>
                                </ul>
                            </div>
                            {:helper('admin/toolbar')->render_button('标签', 'fa fa-tag', 'btn btn-warning selected disabled', array('data-toggle' => 'modal', 'data-target' => '#batch_tagging'))}
                        </div>
                    </div>
                </div>

<style>
.search-rows {
    margin-bottom: 15px;
}
.search-rows .row {
    margin-bottom: 5px;
}
.search-rows .form-control {
	/* .input-sm */
    height: 30px;
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 3px;
}

</style>


                <div class="search-rows form-inline mb-m">
                    <div class="row">
                        <div class="col-sm-4">
                            {:helper('admin/form')->render_group('q_country', isset($where_list['country']) ? $where_list['country'] : '', 'text', '国家')}
                        </div>
                        <div class="col-sm-4">
                            {:helper('admin/form')->render_group('q_province', isset($where_list['province']) ? $where_list['province'] : '', 'text', '省份')}
                        </div>
                        <div class="col-sm-4">
                            {:helper('admin/form')->render_group('q_city', isset($where_list['city']) ? $where_list['city'] : '', 'text', '城市')}
                        </div>
                    </div> 
                    <div class="row">
                        <div class="col-sm-4">
                            {:helper('admin/form')->render_group('q_language', isset($where_list['language']) ? $where_list['language'] : '', 'text', '语言')}
                        </div>
                        <div class="col-sm-4">
                            {:helper('admin/form')->render_group('q_sex', isset($where_list['sex']) ? $where_list['sex'] : '', 'text', '性别')}
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label></label>
                                <button type="button" class="btn btn-info btn-sm form-get">
                                    <i class="fa fa-search "></i>&nbsp;&nbsp;查询
                                </button>
                            </div>
                        </div>
                    </div>    
                </div>

                <div class="row">
                    <div class="col-sm-12">
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                                <tr>
                                    <th class="list-ids">{:helper('admin/table')->render_header_select()}</th>
                                    <th>{:helper('admin/table')->render_header_text('OPENID')}</th>
                                    <th>{:helper('admin/table')->render_header_text('昵称')}</th>
                                    <th>{:helper('admin/table')->render_header_text('头像')}</th>
                                    <th>{:helper('admin/table')->render_header_text('关注')}</th>
                                    <th>{:helper('admin/table')->render_header_text('黑名单')}</th>
                                    <th>{:helper('admin/table')->render_header_text('操作')}</th>
                                </tr>
                            </thead>
                            <tbody>
                                {notempty name="user_list"}
                                    {foreach name="user_list" item="vo"}
                                        <tr>
                                            <td>{:helper('admin/table')->render_column_select($vo['id'], array('selected' => $selected))}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['openid'])}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['nickname'] . ($vo['remark'] ? '(' . $vo['remark'] . ')' : ''))}</td>
                                            <td>{:helper('admin/table')->render_column_image($vo['headimgurl'])}</td>
                                            <td>{:helper('admin/table')->render_column_date_time($vo['subscribe_time'])}</td>
                                            <td>{:helper('admin/table')->render_column_text($vo['blacklist'])}</td>
                                            <td>
                                                {:helper('admin/table')->render_action('修改', 'fa fa-edit', 'btn btn-primary btn-xs form-get', array('url' => $_controller->url('view_user_info', array('id' => $vo['id']))))}
                                            </td>
                                        </tr>
                                    {/foreach}
                                {else /}
                                    {:helper('admin/table')->render_empty_row()}
                                {/notempty}
                            </tbody>
                        </table>

                        {notempty name="user_list"}
                            {:helper('admin/table')->render_paginationx($_controller->url('index', ['page' => '[page]']), $total_rows, $page_num, $page_size, $sort_field, $sort_order)}
                        {/notempty}
                    </div>
                </div>

            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </form>
    
    <div class="modal fade" id="batch_tagging">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">用户标签</h4>
                </div>
                <div class="modal-body">
                    <p>
                        <p>自定义菜单能够帮助公众号丰富界面，让用户更好更快地理解公众号的功能。</p>
                        <p>1、自定义菜单最多包括3个一级菜单，每个一级菜单最多包含5个二级菜单。</p>
                        <p>2、一级菜单最多4个汉字，二级菜单最多7个汉字，多出来的部分将会以“...”代替。</p>
                        <p>3、创建自定义菜单后，菜单的刷新策略是，在用户进入公众号会话页或公众号profile页时，如果发现上一次拉取菜单的请求在5分钟以前，就会拉取一下菜单，如果菜单有更新，就会刷新客户端的菜单。测试时可以尝试取消关注公众账号后再次关注，则可以看到创建后的效果。</p>
                        <p>更多关于自定义菜单的详细详细，请参考<a href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013" target="_blank">《微信公众平台技术文档》</a></p>
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
{/block}
